#include <bits/stdc++.h>

using namespace std;

const int N = 1e5 + 10;

int T;

int n, m, l, V;
int d[N], v[N], a[N];
int p[N];
bool st[N];
int needd;
bool flag = true;

void solve()
{
	scanf("%d%d%d%d", &n, &m, &l, &V);
	
	for (int i = 1; i <= n; ++ i )
	{
		scanf("%d%d%d", &d[i], &v[i], &a[i]);
	}
	
	for (int i = 1; i <= m; ++ i )
	{
		scanf("%d", &p[i]);
	}
	
	int res = 0;

	int idx1 = 0, idx2 = 0;
	for (int i = 1; i <= n; ++ i )
	{

		if (a[i] == 0) // yun zhi =============
		{
			if (v[i] > V)
			{
				if (p[m] >= d[i])
				{
					res ++;
				}
			}
		}
		else if (a[i] > 0) // yun jia +
		{
			flag = false;
			int x = p[m] - d[i];
			
			double vt = sqrt((double)2 * a[i] * x + (double)v[i] * v[i]);

			if (vt > V)
			{
				res ++;
				
			}
			
		}
		else // yun jian -
		{
			int idx = 0;
			for (int j = 1; j <= m; ++ j )
			{
				if (p[j] >= d[i])
				{
					idx = j;
					break;
				}
			}
			int x = p[idx] - d[i];
			double vt = sqrt((double)2 * a[i] * x + (double) v[i] * v[i]);
			if (vt > V)
			{
				res ++;
			}
		}
	}
	
	if (flag == true)
	{
		printf("%d %d\n", res, m - 1);
	}
	
	printf("%d %d\n", res, m - 2);

}

int main()
{
	freopen("detect.in", "r", stdin);
	freopen("detect.out", "w", stdout);
	
	cin >> T;
	
	while (T --)
	{
		solve();
	}
	
	return 0;
}
